Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework evaluation export #127

Merged
merged 146 commits into from
May 14, 2022
Merged

Rework evaluation export #127

merged 146 commits into from
May 14, 2022

Conversation

provinzio
Copy link
Owner

@provinzio provinzio commented May 4, 2022

The tax evaluation and export is currently under major rework. Most of the tax evaluation is done, but could require some more explanatory comments. The export is basically done, but I am still improving the formatting etc.

I'd love to have a helping hand, reviewing the changes, pinpointing code which could be better and so on....
If you have the time, I'd really appreciate it!

@Griffsano @scientes @jhoogstraat



Related #104

provinzio and others added 30 commits April 8, 2022 16:28
normal sum would return Union[decimal.Decimal, Literal[0]] which is unwanted
…rations.list

TODO sell.fees and buy.fees are currently not, but should be, considered for tax calculation
- RENAME class methods
- UPDATE comments
- REFACTOR code
- CHANGE Keep track of home fiat balance
prices from csv are only calculated for exactly one buy/sell pair. merging operations makes sure, that there is only one buy/sell pair
this commit will be removed as soon as i get back to work
@jhoogstraat
Copy link
Contributor

jhoogstraat commented May 14, 2022

I don't know why this is throwing just now, but it does:

eur_subtotal = misc.force_decimal(_eur_subtotal)

_eur_subtotal, _eur_total and _eur_fee are None when the operation is a withdrawal (and potentially deposit and others).
Here is an example from my coinbase statement:
2021-01-01T00:00:00Z,Send,EOS,1,EUR,3,"","","","Sent 1,0000 EOS to binancecleos"

@jhoogstraat
Copy link
Contributor

I am also getting many Unable to correctly determine buy cost of bought coins... warnings with my binance statement. I have to look into that.

@provinzio
Copy link
Owner Author

I am also getting many Unable to correctly determine buy cost of bought coins... warnings with my binance statement. I have to look into that.

Buys and sells always come in a pair (a trade). To determine the buy cost of bought coins, it is necessary to know the "sell"-part of the trade: the sell value is the buying cost of these coins. This is important because (1) the bought coins value might be differ from the sell value and (2) the tax calculation requires you to use the real buying costs for tax calculation (see BMF draft)

Example why is is important:

  • I buy a coin for 1 €, but the coin is at the same time worth 100 €. I just got lucky
  • Now I am selling my coin for 100 €, which it is worth.

You can see, that I gained 99 €. This calculation is only possible, when Buy and Sell pairs got "matched" and the real buying cost of the coin (1 €) is used for tax calculation (100 € (buy value of the sell-trade) - 1 € (sell value of the buy-trade) = 99 €). If Cointaxman can not match the Buy/sell pairs it only sees

  • Sell 1 € (worth 1 €)
  • Buy 1 Coin (worth 100 €)
  • Sell 1 Coin (worth 100 €)
  • Buy 100 € (worth 100 €)

Stupid calculation of the gain calculates 100 € - 100 € = 0 € gain. This is what Cointaxman is currently doing for you, hence the warning. It does not realized which Buys and Sells form a trade-pair.

Now, how can we fix this? The matching is done in book.py:resolve_trades. Currently all operations are grouped by time. If at one time only a buy and sell trade exist: they belong together, chaka! If more than two operations were found, CoinTaxman does nothing, bad.... leading to your warning in the end.

To solve this. We have to extend the functionality of resolve_trades so that it's able to match your trade-pairs together. This is where you come into play. Please check your account statements and see which trades (operations happend at the same time) could'nt been matched. Why weren't they matched and what could we do to match them?

@provinzio
Copy link
Owner Author

I don't know why this is throwing just now, but it does:

eur_subtotal = misc.force_decimal(_eur_subtotal)

_eur_subtotal, _eur_total and _eur_fee are None when the operation is a withdrawal (and potentially deposit and others). Here is an example from my coinbase statement: 2021-01-01T00:00:00Z,Send,EOS,1,EUR,3,"","","","Sent 1,0000 EOS to binancecleos"

fixed as part of #130, already merged into the branch

@provinzio provinzio marked this pull request as ready for review May 14, 2022 22:05
@provinzio provinzio merged commit f1ea6a1 into main May 14, 2022
@provinzio provinzio deleted the rework-evaluation-export branch May 14, 2022 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed report/export Taxman
Projects
None yet
3 participants